﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DotNet.WebUI.LayUI
{
    /// <summary>
    /// DataUsers 的摘要说明
    /// </summary>
    public class DataUsers : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            int _Page = Convert.ToInt32(context.Request.QueryString["page"]);
            int _Limit = Convert.ToInt32(context.Request.QueryString["limit"]);

            context.Response.Write(getUser(_Page, _Limit));
        }

        public string  getUser(int page, int limit)
        {
            string _Result = "";
            int _Count = (page - 1) * limit + limit;
            for (int i = (page - 1) * limit + 1; i <= _Count; i++)
            {
                if (_Result.Length <= 0)
                {
                    _Result = "{" + string.Format("\"LoginID\":\"User-0{0}\",\"UserName\":\"用户—{0}\",\"Depict\":\"日期时间为：{1}\"",
                        i, string.Format(DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss.{0}"), i)) + "}";
                }
                else
                {
                    _Result += ",{" + string.Format("\"LoginID\":\"User-00{0}\",\"UserName\":\"用户—{0}\",\"Depict\":\"日期时间为—{1}\"",
                        i, string.Format(DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss.{0}"), i)) + "}";
                }
            }

            return "{\"code\":0,\"msg\":\"用户数据\",\"count\":1000000,\"data\":[" + _Result + "]}";
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}